<template></template>

<script>
export default {
  name: "HandleShake",
  data() {
    return {
      isDisabledForShake: false,
    };
  },
  methods: {
    /**
     * 启用停用方法
     * @param row
     */
    changeStatus(row) {
      return new Promise((resolve, reject) => {
        reject("请复写停用启用方法");
      });
    },

    /**
     * 保存表单方法
     * * @param params
     */
    submitFormForShake(params) {
      return new Promise((resolve, reject) => {
        reject("请复写保存表单方法");
      });
    },

    /**
     * 防抖通用方法
     */
    handleShake(params, type) {
      if (type && type === "submit") {
        if (!this.isDisabledForShake) {
          this.isDisabledForShake = true;
          this.submitFormForShake(params)
            .then()
            .catch()
            .finally(() => {
              this.isDisabledForShake = false;
            });
        }
      } else {
        if (!params.isDisabledForShake) {
          params.isDisabledForShake = true;
          this.changeStatus(params)
            .then()
            .catch()
            .finally(() => {
              params.isDisabledForShake = false;
            });
        }
      }
    },

    /**
     * 导出方法
     * @param row
     */
    handleExport(row) {
      return new Promise((resolve, reject) => {
        reject("请复写导出方法");
      });
    },

    /**
     * 导出防抖通用方法
     */
    handleShakeExport(params, type) {
      if (!params.isExportForShake) {
        params.isExportForShake = true;
        this.handleExport(params)
          .then()
          .catch()
          .finally(() => {
            params.isExportForShake = false;
          });
      }
    },
  },
};
</script>

<style scoped></style>
